/*
 ----------------------------------------------------------------------------------
                           "THE BEER-WARE COPYRIGHT LICENSE"
                                     (Revision 43)
                                      -----------
    Rymek [rymek@rymek.org] wrote this file. As long as You retain this notice and
    this file has been sent directly to You by the author, You can do whatever You
    want with this stuff as long as You don't sell or rent it. If we meet some day,
    and You think this stuff is worth it, You can buy me a beer in return :-)
                                                                 __________
                                                                 Paweł Rymaszewski
  ----------------------------------------------------------------------------------
 */

package ui.windows.components.panels.searchParametersPanel;

import ui.windows.forms.searchForm.SearchForm;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

/**
 * Performs actions on MessageList combobox
 *
 * @author rymek
 *         User: rymek
 *         Date: 12.08.11
 *         Time: 11:52
 */
class SearchParamsPanelKeyAdapter extends KeyAdapter {

    private final SearchParamsPanel searchParamsPanel;      // parent panel

    /**
     * Constructor.
     * Also sets reference to parent panel.
     *
     * @param searchParamsPanel parent panel
     */
    public SearchParamsPanelKeyAdapter(SearchParamsPanel searchParamsPanel) {
        this.searchParamsPanel = searchParamsPanel;
    }

    /**
     * Performs search action on SearchForm
     *
     * @param e KeyEvent
     */
    @Override
    public void keyPressed(KeyEvent e) {
        super.keyPressed(e);
        if ((e.isShiftDown() || e.isControlDown()) && e.getKeyCode() == KeyEvent.VK_ENTER) {
            ((SearchForm) this.searchParamsPanel.getParentFrame()).getSearchButton().doClick();
        }
    }
}
